using System;

using Taimila.Entify.Attributes;

namespace Taimila.Entify.UnitTests
{
	/// <summary>
	/// Test class that is marked as Entity.
	/// </summary>
	[Entity(Version = 1.0)]
	public class ValidPersistentEntity : Entity
	{	
		[EntityProperty(PersistentName = "NumberProperty")]
		public int Number
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "TextProperty")]
		public string Text
		{
			get;
			set;
		}
	
		[EntityProperty(PersistentName = "LongNumberProperty", IndexName="First Index")]
		public long LongNumber
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "DoubleNumberProperty", IndexName="First Index")]
		public double DoubleNumber
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "DecimalNumberProperty", IndexName="Yet.Another.Index")]
		public decimal DecimalNumber
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "TimestampProperty")]
		public DateTime Timestamp
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "ByteProperty")]
		public byte ByteNumber
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "BooleanProperty")]
		public bool Boolean
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "CharProperty")]
		public char Char
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "SByteProperty")]
		public sbyte SByte
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "ShortProperty")]
		public short Short
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "FloatProperty")]
		public float Float
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "UintProperty")]
		public uint UInt
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "UlongProperty")]
		public ulong ULong
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "UshortProperty")]
		public ushort UShort
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "EnumProperty")]
		public TestEnumeration Enumeration
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "SerializableProperty")]
		public SerializableType SerializableObject
		{
			get;
			set;
		}
	}
	
	
	/// <summary>
	/// Enum type used as property type in test entity.
	/// </summary>
	public enum TestEnumeration
	{		
		Other,
		Some,
		YetAnother
	}
	
	/// <summary>
	/// Serializable object to be used as property type in test entity.
	/// </summary>
	[Serializable]
	public class SerializableType
	{
		public string text = "Test just for testing";
		public int number = 123;
		
		public override bool Equals(object obj)
		{
			SerializableType other;
			if(obj == null)
			{
				return false;	
			}
			else
			{
				other = (SerializableType) obj;
			}
			
			if(!this.text.Equals(other.text))
			{
				return false;
			}
			
			if(this.number != other.number)
			{
				return false;	
			}
			
			return true;
		}
		
		public override int GetHashCode()
		{
			return this.text.GetHashCode() ^ this.number.GetHashCode();
		}

		public override string ToString ()
		{
			return string.Format("[SerializableType] text: " + this.text + " number: " + this.number);
		}
	}
}
